#include<stdio.h>
#include<malloc.h>

typedef struct BTNode
{
    char data;
    struct BTNode *Lchild,*Rchild;
}BTNode,*BTree;

char deal[100];
int count;

BTree Preorder_Create_BTree()
{
    if(deal[count]=='#')
    {
        return NULL;
    }
    else
    {
        BTree T=(BTree)malloc(sizeof(BTNode));
        T->data=deal[count];
        count++;
        T->Lchild=Preorder_Create_BTree(T->Lchild);
        count++;
        T->Rchild=Preorder_Create_BTree(T->Rchild);
        return T;
    }
}

void InTraverse(BTree T)
{
    if(T==NULL) return;
    InTraverse(T->Lchild);
    printf("%c ",T->data);
    InTraverse(T->Rchild);
}

int main()
{
    scanf("%s",deal);
    int count=0;
    BTree root=Preorder_Create_BTree();
    InTraverse(root);
    return 0;
}